import request from '@/router/axios';

/**
 * @param current 当前页
 * @param size 每页数据量
 * @returns {AxiosPromise}
 */
export const getParentList = (current, size,params) => {
  return request({
    url: '/api/hg-logistics/inventory/take/list',
    method: 'get',
    params: {
      ...params,
      current,
      size,
    }
  })
}


export const getChildList = (current, size, transferId) => {
  return request({
    url: '/api/hg-logistics/inventory/take/item/list',
    method: 'get',
    params: {
      transferId,
      current,
      size,
    }
  })
}

export const add = (row) => {
  return request({
    url: '/api/hg-logistics/inventory/take/save',
    method: 'post',
    data: row
  })
}

export const update = (row) => {
  return request({
    url: '/api/hg-logistics/inventory/take/update',
    method: 'post',
    data: row
  })
}

export const remove = (id) => {
  return request({
    url: '/api/hg-logistics/inventory/take/delete',
    method: 'post',
    params: {
      id,
    }
  })
}


export const start = (id) => {
  return request({
    url: '/api/hg-logistics/inventory/take/start',
    method: 'post',
    params: {
      id,
    }
  })
}


export const back = (id) => {
  return request({
    url: '/api/hg-logistics/inventory/take/cancel',
    method: 'post',
    params: {
      id,
    }
  })
}

export const renew = (id) => {
  return request({
    url: '/api/hg-logistics/inventory/take/renew',
    method: 'post',
    params: {
      id,
    }
  })
}


export const createOutput = (id) => {
  return request({
    url: '/api/hg-logistics/inventory/take/createOutput',
    method: 'get',
    params: {
      id,
    }
  })
}


export const setCommit = (id) => {
  return request({
    url: '/api/hg-logistics/inventory/take/commit',
    method: 'post',
    params: {
      id,
    }
  })
}

export const setDone = (id,takeCon) => {
  return request({
    url: '/api/hg-logistics/inventory/take/done',
    method: 'post',
    params: {
      id,
      takeCon,
    }
  })
}


export const getBusinessList = (current,size,params) => {
  return request({
    url: '/api/hg-logistics/business/type/list',
    method: 'get',
    params: {
      ...params,
      current,
      size
    }
  })
}


export const choose = (form) => {
  return request({
    url: '/api/hg-logistics/inventory/manage/choose',
    method: 'post',
    data: form
  })
}


export const addDetail = (row) => {
  return request({
    url: '/api/hg-logistics/inventory/take/item/save',
    method: 'post',
    data: row
  })
}




export const removeDetailList = (ids) => {
  return request({
    url: '/api/hg-logistics/inventory/take/item/delete',
    method: 'post',
    params: {
      ids,
    }
  })
}

export const removeDetail = (id,itemId) => {
  return request({
    url: '/api/hg-logistics/inventory/take/item/deleteItem',
    method: 'post',
    params: {
      id,
      itemId,
    }
  })
}

export const getAreaList = (current, size,params) => {
  return request({
    url: '/api/hg-logistics/inventory/area/list',
    method: 'get',
    params: {
      ...params,
      current,
      size,
    }
  })
}

export const getById = (id) => {
  return request({
    url: '/api/hg-public/material/info/info2',
    method: 'get',
    params: {
      id,
    }
  })
}


export const getPrint = () => {
  return request({
    url: '/api/hg-logistics/inventory/manage/testFile',
    method: 'get',
  })
}


export const getMaterialList = (current,size,inventoryTaeReq) => {
  return request({
    url: '/api/hg-logistics/inventory/manage/take',
    method: 'post',
    params: {
      current,
      size,
    },
    data:inventoryTaeReq,
  })
}

export const getMaterialTypeList = () => {
  return request({
    url: '/api/hg-public/material/type/get-all-second-type',
    method: 'get',
  })
}

export const getChildDetailList = (current, size,materialId,itemId, params) => {
  return request({
    url: '/api/hg-logistics/inventory/take/item/list/item',
    method: 'get',
    params: {
      ...params,
      materialId,
      itemId,
      current,
      size,
    }
  })
}

export const getAreaTypeList = () => {
  return request({
    url: '/api/blade-system/dict-biz/dictionary?code=areaType',
    method: 'get',
  })
}
